package edu.jmu.action.message;

import java.io.Serializable;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import edu.jmu.action.BaseAction;
import edu.jmu.bean.PageView;
import edu.jmu.bean.message.Message;
import edu.jmu.service.message.MessageService;

@Controller 
@Scope(value="prototype")
public class OperateMessageAction extends BaseAction<Message> {
	private static final long serialVersionUID = 8876487905804089928L;
	@Resource
	private MessageService messageService;
	private Message messageBean;
	private Integer[] delIds;
	
	public Integer[] getDelIds() {
		return delIds;
	}

	public void setDelIds(Integer[] delIds) {
		this.delIds = delIds;
	}

	public String messageList(){
		this.pageView = new PageView<Message>(10, 20);
		pageView.setQueryResult(messageService.getScrollData());
		return SUCCESS;
	}
	
	public String addMessage(){
		messageService.save(messageBean);
		return  SUCCESS;
	}
	
	public String editMessage(){
		messageService.update(messageBean);
		return SUCCESS;
	}
	
	public String deleteMessage(){
		messageService.delete((Serializable)delIds );
		return SUCCESS;
	}

	public Message getMessageBean() {
		return messageBean;
	}

	public void setMessageBean(Message messageBean) {
		this.messageBean = messageBean;
	}

}